package com.bruce.dao.impl;

import com.bruce.bean.ClassStudnet;
import com.bruce.bean.Major;
import com.bruce.dao.FindMajor;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author cc
 * @date 2021/7/24 13:39
 * @Description
 */

public class FindMajorimpl extends BaseDao implements FindMajor  {
    @Override
    public List<Major> FindALlMajor() {
        String sql = "select * from major ";
        try {
            List<Major> query = queryRunner.query(sql, new BeanListHandler<Major>(Major.class));
            return query;
        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
        }
        return null;
    }

    @Override
    public List<ClassStudnet> FindClass(int collegeID) {
        String sql = "select * from clazz where majorid = ?";
        try {
            List<ClassStudnet> classstudent = queryRunner.query(sql, new BeanListHandler<ClassStudnet>(ClassStudnet.class),collegeID);
            return classstudent;
        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
        }
        return null;
    }
}
